package com.mc.web.controller.system;

import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.system.domain.SysArea;
import com.mc.system.service.IsysAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/area")
public class SysAreaController extends BaseController {
    @Autowired
    private IsysAreaService sysAreaService;

    @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list/{parentCode}")
    public AjaxResult list(@PathVariable String parentCode){
        SysArea sysArea = new SysArea();
        if(parentCode.equals("province")){
            sysArea.setAdminLevel("province");
        }else{
            sysArea.setParentCode(parentCode);
        }
        return AjaxResult.success(sysAreaService.selectSysAreaList(sysArea));
    }

}
